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

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

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

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

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

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

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

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

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

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

b.r = c
b.w = n
b.v = m
e.y = l
c.v = l
c.r = l
g.p = m
g.q = l
g.s = c
h.r = l
h.w = n
h.v = m
m.p = g
m.q = c
m.s = c
n.r = l
n.w = b
n.v = g
l.v = c
l.r = c
assert h.r.v.r.r.v.v.v.txt == "l"