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

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

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

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

c = A("c")
j = B("j")
m = C("m")
e = D("e")

c.r = j
j.x = c
m.u = c
m.t = j
e.s = m
e.v = m
e.p = c
assert c.r.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
m = C("m")
e = D("e")

c.r = j
j.x = c
m.u = c
m.t = j
e.s = m
e.v = m
e.p = c
assert c.r.x.r.x.txt == "c"