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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: B = None
        self.txt = txt

e = A("e")
n = B("n")
f = C("f")
h = D("h")
i = B("i")

e.t = n
e.v = f
n.p = f
f.w = i
f.v = n
f.x = n
h.v = e
h.w = i
i.p = f
assert n.p.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: B = None
        self.txt = txt

e = A("e")
n = B("n")
f = C("f")
h = D("h")
i = B("i")

e.t = n
e.v = f
n.p = f
f.w = i
f.v = n
f.x = n
h.v = e
h.w = i
i.p = f
assert n.p.x.p.x.txt == "n"