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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.y: A = None
        self.p: C = None
        self.txt = txt

l = A("l")
k = B("k")
m = C("m")
n = D("n")
h = E("h")
j = F("j")
f = B("f")
i = F("i")

l.r = m
k.o = h
m.p = h
n.o = k
h.u = n
h.w = n
j.s = m
j.p = m
j.t = l
j.y = l
f.o = h
i.s = m
i.p = m
i.t = l
i.y = l
assert j.y.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.y: A = None
        self.p: C = None
        self.txt = txt

l = A("l")
k = B("k")
m = C("m")
n = D("n")
h = E("h")
j = F("j")
f = B("f")
i = F("i")

l.r = m
k.o = h
m.p = h
n.o = k
h.u = n
h.w = n
j.s = m
j.p = m
j.t = l
j.y = l
f.o = h
i.s = m
i.p = m
i.t = l
i.y = l
assert j.y.r.p.txt == "h"