class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: E = None
        self.u: A = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: D = None
        self.y: E = None
        self.r: B = None
        self.p: A = None
        self.x: B = None
        self.txt = txt

h = A("h")
e = B("e")
g = C("g")
m = D("m")
k = E("k")
b = F("b")

h.r = m
e.z = h
e.u = h
g.z = e
g.v = e
g.x = k
g.u = h
g.q = m
m.w = b
m.p = b
m.x = k
m.u = h
m.v = h
k.t = g
b.z = h
b.p = h
b.t = m
b.y = k
b.r = e
b.x = e
assert k.t.q.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: E = None
        self.u: A = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: D = None
        self.y: E = None
        self.r: B = None
        self.p: A = None
        self.x: B = None
        self.txt = txt

h = A("h")
e = B("e")
g = C("g")
m = D("m")
k = E("k")
b = F("b")

h.r = m
e.z = h
e.u = h
g.z = e
g.v = e
g.x = k
g.u = h
g.q = m
m.w = b
m.p = b
m.x = k
m.u = h
m.v = h
k.t = g
b.z = h
b.p = h
b.t = m
b.y = k
b.r = e
b.x = e
assert k.t.q.u.r.txt == "m"