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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

c = A("c")
l = B("l")
f = C("f")
b = D("b")
h = B("h")
j = A("j")
n = B("n")
g = C("g")
m = D("m")

c.x = m
c.p = m
c.y = b
l.q = j
f.r = g
b.v = l
b.s = j
h.q = j
j.x = m
j.y = b
j.p = b
n.q = j
g.r = f
m.v = n
m.s = j
assert n.q.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

c = A("c")
l = B("l")
f = C("f")
b = D("b")
h = B("h")
j = A("j")
n = B("n")
g = C("g")
m = D("m")

c.x = m
c.p = m
c.y = b
l.q = j
f.r = g
b.v = l
b.s = j
h.q = j
j.x = m
j.y = b
j.p = b
n.q = j
g.r = f
m.v = n
m.s = j
assert n.q.p.s.txt == "j"