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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: B = None
        self.u: D = None
        self.txt = txt

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

l = A("l")
d = B("d")
h = C("h")
g = D("g")
c = C("c")

l.y = h
l.u = g
l.p = g
l.q = d
d.x = h
d.z = h
h.s = l
h.r = d
h.u = g
g.t = d
c.s = l
c.r = d
c.u = g
assert c.r.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.u: D = None
        self.p: D = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: B = None
        self.u: D = None
        self.txt = txt

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

l = A("l")
d = B("d")
h = C("h")
g = D("g")
c = C("c")

l.y = h
l.u = g
l.p = g
l.q = d
d.x = h
d.z = h
h.s = l
h.r = d
h.u = g
g.t = d
c.s = l
c.r = d
c.u = g
assert c.r.z.s.txt == "l"