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

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

i = A("i")
h = B("h")
g = C("g")
l = D("l")
e = B("e")

i.v = l
i.q = h
i.t = g
h.t = e
g.q = h
g.x = l
l.p = i
e.t = h
assert i.q.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: B = None
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

i = A("i")
h = B("h")
g = C("g")
l = D("l")
e = B("e")

i.v = l
i.q = h
i.t = g
h.t = e
g.q = h
g.x = l
l.p = i
e.t = h
assert i.q.t.t.txt == "h"