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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: D = None
        self.p: D = None
        self.v: E = None
        self.y: D = None
        self.txt = txt

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

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

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

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

a.r = e
a.s = e
b.z = e
b.s = a
e.t = m
e.x = m
e.p = m
e.y = m
e.v = l
m.u = d
l.q = g
d.q = a
g.r = e
g.s = e
assert g.s.t.u.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: D = None
        self.p: D = None
        self.v: E = None
        self.y: D = None
        self.txt = txt

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

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

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

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

a.r = e
a.s = e
b.z = e
b.s = a
e.t = m
e.x = m
e.p = m
e.y = m
e.v = l
m.u = d
l.q = g
d.q = a
g.r = e
g.s = e
assert g.s.t.u.q.r.txt == "e"