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

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

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

b = A("b")
g = B("g")
f = C("f")
a = B("a")
e = B("e")
d = A("d")

b.q = d
b.u = f
b.t = e
g.q = f
g.v = b
f.p = e
a.q = f
a.v = b
e.q = f
e.v = b
d.q = b
d.u = f
d.t = a
assert b.q.t.q.p.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: C = None
        self.t: B = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
f = C("f")
a = B("a")
e = B("e")
d = A("d")

b.q = d
b.u = f
b.t = e
g.q = f
g.v = b
f.p = e
a.q = f
a.v = b
e.q = f
e.v = b
d.q = b
d.u = f
d.t = a
assert b.q.t.q.p.v.q.txt == "d"