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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.z: E = None
        self.o: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.q: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: C = None
        self.txt = txt

f = A("f")
c = B("c")
e = C("e")
g = D("g")
b = E("b")
m = F("m")

f.z = g
f.u = c
c.s = f
c.q = f
c.p = b
e.p = b
e.z = b
e.o = g
g.x = b
g.s = f
g.t = e
b.y = m
b.q = c
m.y = c
m.p = e
assert b.y.y.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.z: E = None
        self.o: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.q: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: C = None
        self.txt = txt

f = A("f")
c = B("c")
e = C("e")
g = D("g")
b = E("b")
m = F("m")

f.z = g
f.u = c
c.s = f
c.q = f
c.p = b
e.p = b
e.z = b
e.o = g
g.x = b
g.s = f
g.t = e
b.y = m
b.q = c
m.y = c
m.p = e
assert b.y.y.q.u.q.txt == "f"