class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.z: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: D = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.z: E = None
        self.u: F = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.p: E = None
        self.v: C = None
        self.r: C = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: B = None
        self.z: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: A = None
        self.txt = txt

a = A("a")
m = B("m")
j = C("j")
c = D("c")
g = E("g")
h = F("h")

a.t = h
a.z = h
m.u = c
m.v = c
m.o = j
j.q = g
j.z = g
j.u = h
j.p = a
c.w = a
c.x = j
c.v = j
c.r = j
c.p = g
c.u = g
g.p = m
g.s = m
g.z = h
h.x = c
h.y = a
assert m.v.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.z: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: D = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.z: E = None
        self.u: F = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.p: E = None
        self.v: C = None
        self.r: C = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: B = None
        self.z: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: A = None
        self.txt = txt

a = A("a")
m = B("m")
j = C("j")
c = D("c")
g = E("g")
h = F("h")

a.t = h
a.z = h
m.u = c
m.v = c
m.o = j
j.q = g
j.z = g
j.u = h
j.p = a
c.w = a
c.x = j
c.v = j
c.r = j
c.p = g
c.u = g
g.p = m
g.s = m
g.z = h
h.x = c
h.y = a
assert m.v.x.p.txt == "a"