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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: A = None
        self.r: D = None
        self.w: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
m = C("m")
g = D("g")
f = E("f")
a = F("a")

l.x = g
l.q = g
l.t = f
d.u = l
d.x = l
d.r = g
d.w = a
m.r = l
g.o = m
f.z = l
f.r = m
a.y = m
a.x = m
a.q = f
a.z = l
a.u = g
assert g.o.r.q.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: E = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: A = None
        self.r: D = None
        self.w: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
m = C("m")
g = D("g")
f = E("f")
a = F("a")

l.x = g
l.q = g
l.t = f
d.u = l
d.x = l
d.r = g
d.w = a
m.r = l
g.o = m
f.z = l
f.r = m
a.y = m
a.x = m
a.q = f
a.z = l
a.u = g
assert g.o.r.q.o.r.txt == "l"