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

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

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

j = A("j")
k = B("k")
d = C("d")
e = A("e")

j.x = d
k.x = d
k.o = d
d.u = e
e.x = d
assert k.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
d = C("d")
e = A("e")

j.x = d
k.x = d
k.o = d
d.u = e
e.x = d
assert k.x.u.x.u.txt == "e"