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

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

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

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

h = A("h")
l = B("l")
e = C("e")
k = D("k")

h.t = l
h.p = k
h.s = k
l.r = h
l.o = h
e.p = k
e.o = l
k.t = e
k.q = l
assert k.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: D = None
        self.s: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
e = C("e")
k = D("k")

h.t = l
h.p = k
h.s = k
l.r = h
l.o = h
e.p = k
e.o = l
k.t = e
k.q = l
assert k.q.o.t.txt == "l"