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

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

i = A("i")
h = B("h")
j = C("j")
m = D("m")
c = B("c")
g = B("g")
l = A("l")

i.r = l
i.v = g
h.p = l
h.y = m
j.x = l
m.t = j
m.p = j
m.s = g
c.p = i
c.y = m
g.p = i
g.y = m
l.r = i
l.v = h
assert g.y.s.y.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: 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.x: A = None
        self.txt = txt

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

i = A("i")
h = B("h")
j = C("j")
m = D("m")
c = B("c")
g = B("g")
l = A("l")

i.r = l
i.v = g
h.p = l
h.y = m
j.x = l
m.t = j
m.p = j
m.s = g
c.p = i
c.y = m
g.p = i
g.y = m
l.r = i
l.v = h
assert g.y.s.y.s.p.txt == "i"