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

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

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

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

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

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

l = A("l")
k = B("k")
b = C("b")
a = D("a")
m = E("m")
g = F("g")
e = F("e")
d = A("d")

l.x = e
k.q = m
b.y = a
b.q = k
b.o = k
a.t = m
m.o = a
m.t = e
m.x = d
g.y = b
g.z = e
g.v = e
g.x = l
g.o = m
e.y = b
e.z = g
e.v = g
e.x = l
e.o = m
d.x = g
assert e.v.v.x.x.y.q.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

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

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

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

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

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

l = A("l")
k = B("k")
b = C("b")
a = D("a")
m = E("m")
g = F("g")
e = F("e")
d = A("d")

l.x = e
k.q = m
b.y = a
b.q = k
b.o = k
a.t = m
m.o = a
m.t = e
m.x = d
g.y = b
g.z = e
g.v = e
g.x = l
g.o = m
e.y = b
e.z = g
e.v = g
e.x = l
e.o = m
d.x = g
assert e.v.v.x.x.y.q.q.x.txt == "d"