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

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

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

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

c = A("c")
l = B("l")
a = C("a")
d = D("d")
b = B("b")
i = A("i")
m = D("m")
e = B("e")
j = C("j")

c.s = i
c.r = m
l.r = a
l.y = d
a.x = j
d.p = a
b.r = j
b.y = d
i.s = c
i.r = d
m.p = a
e.r = a
e.y = d
j.x = a
assert b.y.p.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: D = None
        self.txt = txt

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

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

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

c = A("c")
l = B("l")
a = C("a")
d = D("d")
b = B("b")
i = A("i")
m = D("m")
e = B("e")
j = C("j")

c.s = i
c.r = m
l.r = a
l.y = d
a.x = j
d.p = a
b.r = j
b.y = d
i.s = c
i.r = d
m.p = a
e.r = a
e.y = d
j.x = a
assert b.y.p.x.x.x.txt == "j"