class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: 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.w: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

g = A("g")
j = B("j")
b = C("b")
h = D("h")

g.t = b
g.o = j
j.o = b
b.w = j
h.t = b
assert b.w.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: 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.w: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

g = A("g")
j = B("j")
b = C("b")
h = D("h")

g.t = b
g.o = j
j.o = b
b.w = j
h.t = b
assert b.w.o.w.o.txt == "b"