class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: D = None
        self.t: B = None
        self.w: C = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
g = C("g")
j = D("j")
i = D("i")

l.x = f
l.t = f
l.z = j
l.w = g
f.t = j
g.p = f
j.o = g
i.o = g
assert g.p.t.o.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: D = None
        self.t: B = None
        self.w: C = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
g = C("g")
j = D("j")
i = D("i")

l.x = f
l.t = f
l.z = j
l.w = g
f.t = j
g.p = f
j.o = g
i.o = g
assert g.p.t.o.p.t.txt == "j"