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

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

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

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

a = A("a")
h = B("h")
j = C("j")
k = D("k")
b = A("b")
l = D("l")
g = A("g")

a.r = b
a.t = l
a.w = h
a.v = h
h.t = l
j.p = l
j.v = a
k.t = l
k.y = j
b.r = a
b.t = l
b.w = h
b.v = h
l.t = k
l.y = j
g.r = a
g.t = k
g.w = h
g.v = h
assert j.v.r.w.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: D = None
        self.w: B = None
        self.v: B = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
j = C("j")
k = D("k")
b = A("b")
l = D("l")
g = A("g")

a.r = b
a.t = l
a.w = h
a.v = h
h.t = l
j.p = l
j.v = a
k.t = l
k.y = j
b.r = a
b.t = l
b.w = h
b.v = h
l.t = k
l.y = j
g.r = a
g.t = k
g.w = h
g.v = h
assert j.v.r.w.t.t.t.txt == "l"