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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

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

d = A("d")
n = B("n")
b = C("b")
f = C("f")
g = A("g")
l = B("l")
h = B("h")
k = C("k")
c = C("c")

d.o = k
d.u = f
n.p = f
n.o = b
n.u = d
b.r = g
b.w = c
b.u = h
f.r = g
f.w = k
f.u = h
g.o = f
g.u = f
l.p = c
l.o = k
l.u = d
h.p = k
h.o = b
h.u = g
k.r = g
k.w = c
k.u = l
c.r = d
c.w = b
c.u = l
assert c.r.u.u.p.r.u.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

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

d = A("d")
n = B("n")
b = C("b")
f = C("f")
g = A("g")
l = B("l")
h = B("h")
k = C("k")
c = C("c")

d.o = k
d.u = f
n.p = f
n.o = b
n.u = d
b.r = g
b.w = c
b.u = h
f.r = g
f.w = k
f.u = h
g.o = f
g.u = f
l.p = c
l.o = k
l.u = d
h.p = k
h.o = b
h.u = g
k.r = g
k.w = c
k.u = l
c.r = d
c.w = b
c.u = l
assert c.r.u.u.p.r.u.r.o.txt == "f"