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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

g.x = f
g.q = f
g.o = e
g.r = e
b.o = h
b.z = l
l.p = e
l.u = f
f.r = b
c.v = h
h.u = e
e.x = f
e.q = f
e.o = g
e.r = g
assert g.r.q.r.o.u.txt == "e"