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

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

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

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

h = A("h")
a = B("a")
l = C("l")
b = D("b")
k = B("k")

h.p = k
h.q = k
h.o = k
a.p = l
a.x = h
a.u = h
l.q = a
l.p = b
b.x = k
b.t = k
b.v = a
b.y = l
k.p = l
k.x = h
k.u = h
assert b.y.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

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

h = A("h")
a = B("a")
l = C("l")
b = D("b")
k = B("k")

h.p = k
h.q = k
h.o = k
a.p = l
a.x = h
a.u = h
l.q = a
l.p = b
b.x = k
b.t = k
b.v = a
b.y = l
k.p = l
k.x = h
k.u = h
assert b.y.q.p.txt == "l"