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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: D = 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.r: B = None
        self.u: B = None
        self.x: D = None
        self.txt = txt

l = A("l")
b = B("b")
i = C("i")
c = D("c")
j = D("j")
k = A("k")
h = B("h")

l.x = b
b.p = k
b.y = c
i.q = b
i.p = c
c.r = h
c.u = h
c.x = j
j.r = b
j.u = b
j.x = c
k.x = h
h.p = l
h.y = c
assert i.q.p.x.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: D = 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.r: B = None
        self.u: B = None
        self.x: D = None
        self.txt = txt

l = A("l")
b = B("b")
i = C("i")
c = D("c")
j = D("j")
k = A("k")
h = B("h")

l.x = b
b.p = k
b.y = c
i.q = b
i.p = c
c.r = h
c.u = h
c.x = j
j.r = b
j.u = b
j.x = c
k.x = h
h.p = l
h.y = c
assert i.q.p.x.y.x.x.txt == "c"