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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: B = None
        self.p: D = None
        self.r: A = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: B = None
        self.p: D = None
        self.r: A = None
        self.o: C = None
        self.txt = txt

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

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

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