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

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

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

b = A("b")
e = B("e")
a = C("a")
j = C("j")
d = C("d")

b.r = e
b.t = e
b.q = a
e.x = d
a.v = b
a.s = d
j.v = b
j.s = d
d.v = b
d.s = a
assert j.v.t.x.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.t: B = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
a = C("a")
j = C("j")
d = C("d")

b.r = e
b.t = e
b.q = a
e.x = d
a.v = b
a.s = d
j.v = b
j.s = d
d.v = b
d.s = a
assert j.v.t.x.s.v.txt == "b"