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

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

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

j = A("j")
f = B("f")
n = C("n")
h = B("h")
d = B("d")
i = B("i")

j.x = h
f.o = n
n.o = d
h.o = n
d.o = n
i.o = n
assert i.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
n = C("n")
h = B("h")
d = B("d")
i = B("i")

j.x = h
f.o = n
n.o = d
h.o = n
d.o = n
i.o = n
assert i.o.o.o.o.txt == "d"